using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ballent2 : MonoBehaviour
{
    public int face;
    public float Runspeed;
    private Rigidbody2D myRigidbody;
    public float damage;
    public int RepelTimes;
    public float RepelDistance, StiffTime;
    public float dietime;
    public Vector2 forward;
    void Start()
    {
        myRigidbody = GetComponent<Rigidbody2D>();
        damage = GameObject.FindWithTag("Attack").GetComponent<PlayerAttack>().truedamage;
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {

            other.GetComponent<EnemyBasic>().TakeDamage(damage, face, RepelTimes, RepelDistance, StiffTime);
        }
        if (other.gameObject.CompareTag("GrindingTower"))
        {

            other.GetComponent<Grinding>().TakeDamage(damage);
        }
    }
    // Update is called once per frame
    void Update()
    {
        dietime -= Time.deltaTime;
        if (dietime <= 0) Destroy(gameObject);
        Vector2 vel = new Vector2(forward.x*Runspeed, forward.y * Runspeed);
        myRigidbody.velocity = vel;
    }
}
